package com.htc.callcare.datacontroller;

import android.content.Context;
import android.util.Log;

import com.htc.callcare.database.Database;
import com.htc.callcare.infrastructure.globalVar;

public class OneMinuteTimer extends Thread{

	boolean oneminuteTimeout = false;
	Context context;
	String phonenumber;
	public OneMinuteTimer(String phonenumber,Context context) {
		super();
		this.context = context;
		this.phonenumber = phonenumber;
	}

	public boolean isOneminuteTimeout() {
		return oneminuteTimeout;
	}

	@Override
	public void run() {
		for(int i = 0;i<globalVar.oneMinuteTimeOut;i++){
			try {
				Thread.sleep(1000);
				oneminuteTimeout = false;
				if(i == globalVar.oneMinuteTimeOut-1){
					oneminuteTimeout = true;
					Log.v("thuutai", "Time Out 1 Minute");
					Database db = new Database(context);
					db.updateTimeOut(phonenumber, 1);
				}
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}
